#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>



int main()
{
  int fd = open("log.txt", O_RDWR | O_CREAT | O_TRUNC, 0666); 
  
  char str[] = "i like linux\n";
  write(fd, str, strlen(str));
  
  char str_read[1024];
  lseek(fd, 0, SEEK_SET); 
  read(fd, str_read, strlen(str));
  printf("%s", str_read);

  close(fd); 
  
  return 0;
}
